package jf.jextn.converter;

public class EnumConverter<O extends Enum<O>> implements StringValueConverter<O> {
    private Class<O> enumType;

    public EnumConverter() {
    }

    public EnumConverter(Class<O> enumType) {
        this.enumType = enumType;
    }

    @Override
    public O from(String value) {
        return Enum.valueOf(enumType, value);
    }

    @Override
    public String to(O o) {
        return o.name();
    }

}
